<template>
    <div>
        <el-form ref="form" :model="loginForm">
            <h3>系统登陆</h3>
            <el-form-item>
                <el-input v-model="loginForm.username" placeholder="用户名"></el-input>
                <el-input v-model="loginForm.password" placeholder="密码"></el-input>
                <el-input v-model="loginForm.code"></el-input>
                <el-button type="primary" @click="userlogin()">登录</el-button>
            </el-form-item>
        </el-form>
        <img :src="captchaUrl" @click="updateCaptcha">
    </div>
</template>

<script>
    export default {
        name: "login",
        data(){
            return{
                loginForm:{
                    username:"",
                    password:"",
                    code:""
                },
                captchaUrl:'/captcha?time='+new Date(),
            }
        },
        created() {
        },
        methods:{
            // userlogin(){
            //     this.$http({
            //         url:'/login',
            //         method: 'post',
            //         data:this.loginForm
            //     }).then(result=>{
            //         return result;
            //     }).then((res)=>{
            //         console.log(res)
            //     })
            // },
            userlogin(){
                this.postRequest('/login',this.loginForm).then(result=>{
                    console.log(result);
                })
            },
            updateCaptcha(){
                this.captchaUrl='/captcha?time='+new Date();
            }
        }
    }
</script>

<style scoped>

</style>